/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import abstractmodel.InfoValue;

/**
 *
 * @author fightfxj
 */
public class MoneyAccountInfo implements abstractmodel.IInfo {
    private String accountName;           //帐户名称 长度不超过20 的字符串
    public static String[] titles = new String[]{"帐户名称"};
    private int id;

    public MoneyAccountInfo() {
        accountName = new String("现金帐户名称");
    }
    
    public String getAccountName() {
        return accountName;
    }
    
    @Override
    public String[] getTitles() {
        return MoneyAccountInfo.titles;
    }

    @Override
    public InfoValue getValue(String title) {
        InfoValue iv = new InfoValue();
        iv.setType(this.getClass());
        if (title.equals("帐户名称")) {
            iv.setObj(this.accountName);
            iv.setType(String.class);
        }
        else if (title.equalsIgnoreCase("id")) {
            iv.setObj(new Integer(this.id).toString());
            iv.setType(String.class);
        }          
        return iv;
    }

    @Override
    public boolean setValue(String title, Object value) {
        if (title.equals("帐户名称")) {
            this.accountName = value.toString();
        }
        ModelFactory.data.saveUser(ModelFactory.ur);
        return true;
    }

    @Override
    public int getid() {
        return this.id;
    }

    @Override
    public void setId(int id) {
        this.id = id;
    }

    @Override
    public int getType() {
        return configure.Global.MONEY_ACCOUNT_INFO_TYPE;
    }

}
